﻿using System;

namespace NetTopologySuite.GeometriesGraph.Index
{
	public class SweepLineEvent : IComparable
	{
		public SweepLineEvent(object label, double x, object obj)
		{
			this._eventType = 1;
			this._label = label;
			this._xValue = x;
			this._obj = obj;
		}

		public SweepLineEvent(double x, SweepLineEvent insertEvent)
		{
			this._eventType = 2;
			this._xValue = x;
			this._insertEvent = insertEvent;
		}

		public bool IsInsert
		{
			get
			{
				return this._eventType == 1;
			}
		}

		public bool IsDelete
		{
			get
			{
				return this._eventType == 2;
			}
		}

		public SweepLineEvent InsertEvent
		{
			get
			{
				return this._insertEvent;
			}
		}

		public int DeleteEventIndex
		{
			get
			{
				return this._deleteEventIndex;
			}
			set
			{
				this._deleteEventIndex = value;
			}
		}

		public object Object
		{
			get
			{
				return this._obj;
			}
		}

		public bool IsSameLabel(SweepLineEvent ev)
		{
			return this._label != null && this._label == ev._label;
		}

		public int CompareTo(object o)
		{
			SweepLineEvent sweepLineEvent = (SweepLineEvent)o;
			if (this._xValue < sweepLineEvent._xValue)
			{
				return -1;
			}
			if (this._xValue > sweepLineEvent._xValue)
			{
				return 1;
			}
			if (this._eventType < sweepLineEvent._eventType)
			{
				return -1;
			}
			if (this._eventType > sweepLineEvent._eventType)
			{
				return 1;
			}
			return 0;
		}

		private const int Insert = 1;

		private const int Delete = 2;

		private readonly object _label;

		private readonly double _xValue;

		private readonly int _eventType;

		private readonly SweepLineEvent _insertEvent;

		private int _deleteEventIndex;

		private readonly object _obj;
	}
}
